package com.k.kppcloud.modules.system.controller;

import com.k.kppcloud.modules.system.util.WebUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 170623910 on 2021/10/4.
 */
@Controller
@RequestMapping("/system")
public class SystemController {
    @GetMapping("/userList")
    public void userList(HttpServletRequest request, HttpServletResponse response){
        System.out.println("=============== kppcloud-system/system in");
        String msg = "/system/**  all come in";
        WebUtils.writeOut(response,msg);
    }
    @GetMapping("/byzero")
    public void byzero(HttpServletRequest request, HttpServletResponse response){
        System.out.println("=============== kppcloud-system/byzero in");
        /*
        有异常会返回
        {
 "timestamp": "2021-10-05T02:14:15.396+00:00",
 "path": "/kppcloud-system/system/index",
 "status": 500,
 "error": "Internal Server Error",
 "requestId": "cf59cc7f-2"
 }
         */
        System.out.println(1/0);

    }

    @GetMapping("/a")
    public ResponseEntity testres(HttpServletRequest request, HttpServletResponse response){
        ResponseEntity responseEntity = ResponseEntity.status(HttpStatus.OK).body("oper success");
        ResponseEntity.ok()
                .header("Custom-Header", "foo")
                .body("Custom header set");
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("str");
    }

}
